public class SpinningDiskDevice 
{
   private int lastInput;
   private int transitions;

   /**
      Constructs a spinning disk device.
   */
   public SpinningDiskDevice()
   {
      lastInput=0;
      transitions=0;
   }

   /**
      Processes a new input
      @param input 0 or 1
   */
   public void add(int input)
   {
      if(lastInput==input)
      transitions++;
   }

   /**
      Gets the number of transitions observed since this
      device has been constructed.
   */
   public int getTransitions()
   {
      return transitions;
   }
}